home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / plug-ins / perl / examples / innerbevel < prev    next >
Encoding:
Text File  |  2000-05-21  |  3.4 KB  |  99 lines

  1. #!/usr/app/bin/perl 
  2.  
  3. eval 'exec /usr/app/bin/perl  -S $0 ${1+"$@"}'
  4.     if 0; # not running under some shell
  5. # Effect taken from http://tigert.gimp.org/gimp/tutorials/beveled_text/
  6. # perl-ified by Seth Burgess <sjburges@gimp.org>
  7.  
  8. # Programatically, this script is about as dull as they come.  The only 
  9. # exceptions are those of the neat util functions (that aren't all quite
  10. # working btw).  You can follow step by step with the website at 
  11. # http://tigert.gimp.org/gimp/tutorials/beveled_text/
  12.  
  13. use Gimp qw(:auto __ N_);
  14. use Gimp::Fu;
  15. use Gimp::Util;
  16.  
  17. N_"/Xtns/Render"; N_"/Xtns/Render/Logos"; # i18n workaround
  18.  
  19. $defaultcolor1 = [124,10,18];
  20. $defaultcolor2 = [200,19,27];
  21.  
  22. $path = N_"<Toolbox>/Xtns/Render/Logos/Inner Bevel...";
  23. $shortdesc = "Perform an inner bevel on text";
  24. $longdesc = "This uses tigert's inner bevel method on text, which can be found with his other excellent tutorials at http://tigert.gimp.org/";
  25. $date = "1999-03-23";
  26. $imgtypes = undef;
  27. $author = "Seth Burgess <sjburges\@gimp.org>";
  28.  
  29. $regname = "inner_bevel";
  30.  
  31. $author =~ m/^(.*) </;
  32. $authorname = $1;
  33.  
  34. register $regname, $shortdesc, $longdesc, $authorname, $author, $date, $path, $imgtypes,
  35.   [ 
  36.    [PF_FONT, "font", "Font Name"],
  37.    [PF_STRING, "text", "Enter your text to be beveled", "INNERBEVEL"],
  38.    [PF_COLOR, "top_color", "Blend to this color", $defaultcolor2],
  39.    [PF_COLOR, "bot_color", "Blend from this color", $defaultcolor1],
  40.    [PF_SLIDER, "azimuth", "Direction of the shine", 132, [0,255,5]],
  41.    [PF_SLIDER, "shinyness", "How shiny the final image will be",30, [0,90,5]],
  42.    [PF_SLIDER, "depth_shape", "Determines the final shape", 34 , [0,64,32]], 
  43.    [PF_RADIO, "map", "The type of Map to use", 2, [Linear => 0, Spherical => 1, Sinusoidal => 2] ], 
  44.   ],[],
  45.   [
  46.    'gimp-1.1',
  47.   ], sub {
  48.  
  49. my ($font, $text, $color1, $color2, $azimuth, $elevation, $depth, $maptype) = @_;
  50. # -- step 1 -- 
  51.  
  52. gimp_palette_set_background($color1);
  53. gimp_palette_set_foreground($color2);
  54.  
  55. @dims = gimp_text_wh($text, $font);
  56.  
  57. $img = gimp_image_new($dims[0]+10, $dims[1]+10, RGB);
  58.  
  59. # none of the macro's did quite what I was looking for here.  
  60. # i.e. create a text layer on transparent only...
  61.  
  62. # -- step 2 --
  63. $layertmp = $img->add_new_layer(0,TRANS_IMAGE_FILL);
  64. $txtlayer = $img->text_fontname(-1, 10, 10, $text, 0, 1, xlfd_size($font), $font);
  65. $dsp = gimp_display_new($img);  # display the image early
  66. $layer = $img->merge_visible_layers(EXPAND_AS_NECESSARY);
  67. @pt1 = ($layer->width * 0.5 -1, 0);
  68. @pt2 = ($layer->width * 0.5 +1, $layer->height);
  69. # -- step 3 --
  70. $layer->set_preserve_trans(1);
  71. $layer->blend(FG_BG_RGB, 0, LINEAR, 100, 0, REPEAT_NONE, 0, 3, 0.20, @pt1, @pt2); # NORMAL isn't recognized
  72. # -- step 4 -- 
  73. $layer2 = $layer->copy(0);     # Can you override these to have a default? (would be nice)
  74. $img->add_layer($layer2, 0);
  75. # -- step 5 -- 
  76. $layer2->set_preserve_trans(1);
  77. $img->selection_all;
  78. gimp_palette_set_background([255,255,255]);
  79. $layer2->edit_fill(BG_IMAGE_FILL);
  80. # -- step 6 -- 
  81. $layer2->set_preserve_trans(0);
  82. $layer2->gauss_rle(6,1,1);     # Defaults would be cool here too :)
  83. # -- step 7 --
  84. $layer->plug_in_bump_map($layer2, $azimuth, $elevation, $depth, 0,0,0,0,1,0,$maptype);
  85. # -- step 8 --
  86. $layer2->invert;
  87. $img->lower_layer($layer2);
  88. # -- step 9 --
  89. $layer2->translate(2, 3);
  90.  
  91. # extra stuff
  92. $img->add_new_layer(2);
  93. $img->gimp_selection_none();
  94.  
  95. return();
  96. };
  97.  
  98. exit main;  # <-- This lil' bugger caused me much grief.  I suppose its very much required?
  99.